package com.sun.androidexerciseproject.function.util;

import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.ShortBuffer;

/**
 * Description:
 * File: BufferTest.java
 * Author: Administrator
 * Create: 2019/10/31 15:56
 */
public class BufferTest implements AutoCloseable {
    public static void main(String[] args) {
        byte[] bytes = new byte[]{1, 2, 3};
        short[] shortBytes = new short[]{2, 3, 4, 5};
        double[] doubleBytes = new double[]{3, 4, 5, 6, 7};

        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
        ShortBuffer shortBuffer = ShortBuffer.wrap(shortBytes);
        DoubleBuffer doubleBuffer = DoubleBuffer.wrap(doubleBytes);
        System.out.println("byteBuffer " + byteBuffer.isReadOnly() + " capacity " + byteBuffer.capacity() + " content " + byteBuffer.toString());
        System.out.println("shortBuffer " + shortBuffer.isReadOnly() + " capacity " + shortBuffer.capacity() + " content " + shortBuffer.toString());
        System.out.println("doubleBuffer " + doubleBuffer.isReadOnly() + " capacity " + doubleBuffer.capacity() + " content " + doubleBuffer.toString());
        try (BufferTest test = new BufferTest()) {
//            test.test();
        } catch (Exception e) {
        }
    }

    @Override
    public void close() throws Exception {
        System.out.println("close !!!");
    }

    private void test() {
        System.out.println("test !!!");
    }
}
